<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DOM对象</title>
    <style>
        #hover>span{
            display: inline-block;
            width: 100px;
            height: 100px;
            text-align: center;
            padding-top: 50px;
        }
        #hover>span:hover{
            background-color: #0043d3;
        }
        .red{
            color: red;
        }
        .font{
            font-size: 50px;
        }
    </style>
</head>
<body>
<!--    <span>1</span>-->
<!--    <span>2</span>-->
    <label>
        <input type="text">
    </label>
    <div id="hover">
        <span>X</span>
        <span>Y</span>
    </div>
    <script>
        var spans=document.getElementsByTagName("span")
        var inputs=document.getElementsByTagName("input")
        inputs[0].oninput=function (){
            if (inputs[0].value){
                spans[0].innerText=inputs[0].value
                console.log(inputs[0].value)
            }
        }
        var spans2=document.getElementById("hover")
        // 设置title 属性
        spans2.children[0].setAttribute("title","这是个标题")
        spans2.children[1].setAttribute("title",spans2.children[0].getAttribute('title'))
        var divs=document.getElementById("hover")
        // 设置div的背景样式
        // 1.
        divs.style.backgroundColor="blue"
        // 2.
        // 设置div的文本颜色和文本尺寸
        divs.className="red font"

    </script>
</body>
</html>